package com.windaka.elements.exception;


import com.windaka.elements.constant.ExceptionConstant;
import lombok.Data;
import lombok.EqualsAndHashCode;


/**
 * <p><strong>自义定结果错误异常</strong></p>
 * <li>
 * <p>
 *     <strong>示例1: 默认</strong> <br>
 *             throw new ResultException();
 * </p>
 * </li>
 * <li>
 * <p>
 *     <strong>示例2: 只传入msg</strong> <br>
 *             throw new ResultException(
 *                     msg
 *             );
 * </p>
 * </li>
 * <li>
 * <p>
 *     <strong>示例3: 传入code和msg</strong> <br>
 *             throw new ResultException(
 *                     code,
 *                     msg
 *             );
 * </p>
 * </li>
 * @author song
 * @see BaseException
 * @since 14:23 2021/8/6
 **/
@EqualsAndHashCode(callSuper = true)
@Data
public class ResultException extends BaseException {

    /**
     * 返回信息
    **/
    private String msg;

    /**
     * 返回code
    **/
    private String code;

    /**
     * <p><strong>自义定结果错误异常</strong></p>
     * <li>
     * <p>
     *     <strong>示例1: 默认</strong> <br>
     *             throw new ResultException();
     * </p>
     * </li>
     * <li>
     * <p>
     *     <strong>示例2: 只传入msg</strong> <br>
     *             throw new ResultException(
     *                     msg
     *             );
     * </p>
     * </li>
     * <li>
     * <p>
     *     <strong>示例3: 传入code和msg</strong> <br>
     *             throw new ResultException(
     *                     code,
     *                     msg
     *             );
     * </p>
     * </li>
     * @author song
     * @see BaseException
     * @since 14:23 2021/8/6
     **/
    public ResultException() {
        super(ExceptionConstant.DEFAULT_ERROR_MSG);
    }

    /**
     * <p><strong>自义定结果错误异常</strong></p>
     * <li>
     * <p>
     *     <strong>示例1: 默认</strong> <br>
     *             throw new ResultException();
     * </p>
     * </li>
     * <li>
     * <p>
     *     <strong>示例2: 只传入msg</strong> <br>
     *             throw new ResultException(
     *                     msg
     *             );
     * </p>
     * </li>
     * <li>
     * <p>
     *     <strong>示例3: 传入code和msg</strong> <br>
     *             throw new ResultException(
     *                     code,
     *                     msg
     *             );
     * </p>
     * </li>
     * @author song
     * @see BaseException
     * @since 14:23 2021/8/6
     **/
    public ResultException(String msg) {
        super(msg);
        this.msg = msg;
    }

    /**
     * <p><strong>自义定结果错误异常</strong></p>
     * <li>
     * <p>
     *     <strong>示例1: 默认</strong> <br>
     *             throw new ResultException();
     * </p>
     * </li>
     * <li>
     * <p>
     *     <strong>示例2: 只传入msg</strong> <br>
     *             throw new ResultException(
     *                     msg
     *             );
     * </p>
     * </li>
     * <li>
     * <p>
     *     <strong>示例3: 传入code和msg</strong> <br>
     *             throw new ResultException(
     *                     code,
     *                     msg
     *             );
     * </p>
     * </li>
     * @author song
     * @see BaseException
     * @since 14:23 2021/8/6
     **/
    public ResultException(String code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    public ResultException(Throwable t) {
        super(t);
    }

    public ResultException(String msg, Throwable t) {
        super(msg, t);
    }
}
